from applications.extensions import db


class FundIndexEva(db.Model):
    __tablename__ = 'fund_index_eva'

    index_id = db.Column(db.BigInteger, primary_key=True)
    index_code = db.Column(db.String(255, 'utf8mb4_bin'), comment='指数的代码')
    name = db.Column(db.String(255, 'utf8mb4_bin'), comment='指数名称')
    ttype = db.Column(db.String(255, 'utf8mb4_bin'), comment='指数类型')
    pe = db.Column(db.Numeric(10, 2), comment='pe 指标的数值')
    pb = db.Column(db.Numeric(10, 2), comment='pb 指标的数值')
    pe_percentile = db.Column(db.Numeric(10, 2), comment='pe 百分位')
    pb_percentile = db.Column(db.Numeric(10, 2), comment='pb 百分位')
    roe = db.Column(db.Numeric(10, 2), comment='净资产收益率')
    yeild = db.Column(db.Numeric(10, 2), comment='股息率')
    peg = db.Column(db.Numeric(10, 2), comment='预测 peg')
    ts_at = db.Column(db.BigInteger, comment='时间戳')
    eva_type = db.Column(db.String(255, 'utf8mb4_bin'), comment='指数估值类型，low')
    eva_type_int = db.Column(db.Integer, comment='指数估值类型的整数表示')
    fund_url = db.Column(db.String(255, 'utf8mb4_bin'), comment='基金 url')
    bond_yeild = db.Column(db.Numeric(10, 2), comment='债权收益率')
    create_date = db.Column(db.Date, comment='指数估值时间')

    def __repr__(self):
        return '[%r,%r]' % (self.index_code, self.name)
